/**
 * @author jianghongjun
 * @date 2016-08-09
 * @version 1.0.0
 * @ToDo 事件需要优化
 */
$(function(){

    /* 头部专题事件 */
    var selectColorEvent = function(){

        $(this).parent().find("li").removeClass("selected");
        $(this).addClass("selected");

        var tempElementObj = $(".nav-list");
        var tempSunElementObj = $(".nav-list").find(".mavenItem");
        var tempDownMavenElementObj = $(".sum-maven");
        var colorNo = $(this).find("span").attr("value");

        tempElementObj.removeClass();
        tempElementObj.addClass("nav-list");
        tempElementObj.addClass("nav-style" + colorNo);

        tempSunElementObj.removeClass();
        tempSunElementObj.addClass("nav-item-style" + colorNo);
        tempSunElementObj.addClass("mavenItem");

        tempDownMavenElementObj.removeClass();
        tempDownMavenElementObj.addClass("sum-maven");
        tempDownMavenElementObj.addClass("nav-item-style" + colorNo);

    };

    /* 底部专题事件 */
    var selectBottomColorEvent = function(){

        $(this).parent().find("li").removeClass("selected");
        $(this).addClass("selected");

        var tempElementObj = $(".bottom-declare");
        var tempElementObj1 = $(".declare-content1");
        var tempElementObj2 = $(".declare-content2");
        var colorNo = $(this).find("span").attr("value");

        tempElementObj.removeClass();
        tempElementObj1.removeClass();
        tempElementObj2.removeClass();

        switch(colorNo){
            case "1":
                    tempElementObj.addClass("bottom-declare");
                    tempElementObj1.addClass("declare-content1");
                    tempElementObj2.addClass("declare-content1");
                break;
            case "2":
                    tempElementObj.addClass("bottom-declare");
                    tempElementObj.addClass("black-declare");
                    tempElementObj1.addClass("declare-content2");
                    tempElementObj2.addClass("declare-content2");
                break;
        }

    };

    var downThemenEvent = function(){
        var colorNo = $(".colorSelect").find(".selected").find("span").attr("value");

        var str = "<script type='text/javascript' src='http://img2.kunming.cn/zhuanti/TMDlibrary/js/createDomElement.js?type=nav&color=" + colorNo + "'></script>";

        $("#one").val(str);
    };

    var downCustomEvent = function(){

        var str = "<script type='text/javascript' src='http://img2.kunming.cn/zhuanti/TMDlibrary/js/createDomElement.js?type=navCustom&color=1'></script>";

        $("#two").val(str);
    };

    var downBottomEvent = function(){
        var colorNo = $(".colorCustomSelect").find(".selected").find("span").attr("value");

        var str = "<script type='text/javascript' src='http://img2.kunming.cn/zhuanti/TMDlibrary/js/createDomElement.js?type=bottom&color=" + colorNo + "'></script>";

        $("#three").val(str);
    };

    var downThemeImgEvent = function(){
        var colorNo = $(".colorSelect").find(".selected").find("span").attr("value");
        window.open("../css/images/menu" + colorNo + ".jpg","","toolbar=no,scrollbars=no,menubar=no");
    };

    var downCustomImgEvent = function(){
        window.open("../css/images/menu6.jpg","","toolbar=no,scrollbars=no,menubar=no");
    };

    $(".colorSelect").find("li").on("click", selectColorEvent);
    $(".colorCustomSelect").find("li").on("click", selectBottomColorEvent);
    $(".downTheme").on("click", downThemenEvent);
    $(".downCustom").on("click", downCustomEvent);
    $(".downBottom").on("click", downBottomEvent);
    $(".downThemeImg").on("click", downThemeImgEvent);
    $(".downCustomImg").on("click", downCustomImgEvent);

});
